﻿namespace SsisLdapSource
{
    using System;

    using Microsoft.SqlServer.Dts.Runtime.Wrapper;

    public static class DotNetToSSISTypeMapper 
    {
        public static DataType SSISTypeEquivalent(Type dotNetType, uint length = 0)
        {
                switch (dotNetType.Name)
                {
                    case "Guid":
                        return DataType.DT_GUID;

                    case "SecurityIdentifier":
                        return DataType.DT_BYTES;

                    case "Boolean":
                        return DataType.DT_BOOL;

                    case "Byte[]":
                        return length <= 8000 ? DataType.DT_BYTES : DataType.DT_IMAGE;

                    case "DateTime":
                        return DataType.DT_DBTIMESTAMP;

                    case "Int32":
                        return DataType.DT_I4;

                    default:
                        return DataType.DT_WSTR;
                }
            }
        }
    }

